<?php

namespace app\data\controller\control;
use think\admin\Controller;

/**
 * 领用报表
 * Class Goods
 * @package app\data\controller\shop
 */
class ClaimSheet extends Controller
{
    /**
     * 绑定数据表
     * @var string
     */
    private $table = 'sn_control_claim_list';

    /**
     * 最大分类等级
     * @var integer
     */
    protected $cateLevel;

    /**
     * 领用报表管理
     * @auth true
     * @menu true
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function index()
    {
        $this->title = '仓库数据管理';
        $query = $this->_query($this->table);
        // 列表排序并显示
        $query->like('material_code,plan_id,material_name,admin_name')->dateBetween('plan_time')->where('status',1);
        $query->equal('status')->order('create_at desc')->page();
    }

    /**
     * 数据列表处理
     * @param array $data
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    protected function _page_filter(array &$data)
    {
        $heji = 0;
        $num = 0;
        foreach ($data as $key=>$val){
            $heji += $val['material_xjprice'];
            $num += $val['material_num'];
        }
        $this->assign('heji',$heji);
        $this->assign('num',$num);
    }

    /**
     * 删除仓库数据
     * @auth true
     * @throws \think\db\exception\DbException
     */
    public function remove()
    {
        $this->_save($this->table, $this->_vali([
            'deleted.in:0,1'  => '状态值范围异常！',
            'deleted.require' => '状态值不能为空！',
        ]), 'id');
    }

}